package cn.yh.hospitalappointmentsystemdemo.controller;

import cn.yh.hospitalappointmentsystemdemo.common.AjaxResult;
import cn.yh.hospitalappointmentsystemdemo.common.TableDataInfo;
import cn.yh.hospitalappointmentsystemdemo.controller.base.BaseController;
import cn.yh.hospitalappointmentsystemdemo.domain.vo.ScheduleVo;
import cn.yh.hospitalappointmentsystemdemo.service.IDoctorScheduleService;
import cn.yh.hospitalappointmentsystemdemo.utils.JWTUtils;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@Api(tags = "医生日程管理")
@RestController
@RequestMapping("/schedule")
public class DoctorScheduleController extends BaseController {
    @Autowired
    private IDoctorScheduleService doctorScheduleService;

    @GetMapping("/list")
    public AjaxResult list(){
        if (!doctorScheduleService.refreshSchedule()){
            return AjaxResult.error("刷新数据失败");
        }
        List<ScheduleVo> scheduleVos = doctorScheduleService.getDoctorSchedule(JWTUtils.getUserIdByClaim());
        return AjaxResult.success(scheduleVos);
    }

    @GetMapping("/refresh")
    public AjaxResult refresh(){
        if (!doctorScheduleService.refreshSchedule()){
            return AjaxResult.error();
        }
        return AjaxResult.success();
    }

}
